package com.btcode.schedule;

import java.util.HashMap;
import org.quartz.JobKey;

public final class JobInstanceHolder {

    private HashMap<JobKey, SingleInstanceJob> instanceMap = new HashMap<>();

    private volatile static JobInstanceHolder instance;

    private JobInstanceHolder() {

    }

    public static JobInstanceHolder getInstance() {
        if (instance == null) {
            synchronized (JobInstanceHolder.class) {
                if (instance == null) {
                    instance = new JobInstanceHolder();
                }
            }
        }
        return instance;
    }

    public SingleInstanceJob getJobInstance(JobKey key) {
        return instanceMap.get(key);
    }

    public void putJobInstance(JobKey key, SingleInstanceJob instanceJob) {
        instanceMap.put(key, instanceJob);
    }

}
